package com.atguigu.gmall.user.service.impl;

import com.alibaba.nacos.common.util.Md5Utils;
import com.atguigu.gmall.model.user.UserInfo;
import com.atguigu.gmall.user.mapper.UserInfoMapper;
import com.atguigu.gmall.user.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public UserInfo login(UserInfo userInfo) {
        String MD5Pwd = Md5Utils.getMD5(userInfo.getPasswd(), "UTF-8");
        UserInfo info = userInfoMapper.selectOne(new QueryWrapper<UserInfo>()
                .eq("login_name", userInfo.getLoginName())
                .eq("passwd", MD5Pwd));
        if (null != info)
            return info;
        return null;
    }

    @Override
    public UserInfo regist(UserInfo userInfo) {
        return null;
    }
}
